<!DOCTYPE html>
<html>
<head lang="en">
    <%include ../base/include.ejs%>
    <script type="text/javascript" charset="utf-8" src="/plugin/ueditor1_4_3-utf8-jsp/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="/plugin/ueditor1_4_3-utf8-jsp/ueditor.all.js"> </script>
    <script type="text/javascript" charset="utf-8" src="/plugin/ueditor1_4_3-utf8-jsp/lang/zh-cn/zh-cn.js"> </script>
</head>
<body>
    <%include ../base/menu.ejs%>
    <div class="container ya-content">
        <div class="row">
            <div class="col-md-12">
                <div class="pull-left" style="width:10%">
                    <input id="tag" type="text" class="form-control" placeholder="Tag" value="<%=article.tag%>"/>
                </div>
                <div class="pull-left" style="width:90%">
                    <input id="title" type="text" class="form-control" placeholder="文章标题" value="<%=article.title%>"/>
                </div>
            </div>
            <div class="col-md-12 form-group">
                <script id="editor" type="text/plain" style="width:100%;min-height:400px;">
                    <%-article.content%>
                </script>
            </div>
            <div class="col-md-12 form-group">
                <button class="btn btn-default" id="submit">提交</button>
            </div>
        </div>
    </div>
</body>
<script>
    var id = "<%=article.id%>";
    var ue = UE.getEditor('editor');
    $(document).ready(function (){
        $("#submit").on("click", submit);
    });

    function submit(){
        var tag = $("#tag").val();
        var title = $("#title").val();
        var content = ue.getContent();
        id = id || '';
        alert(id);
        $.ajax({
            url : "/article/insert",
            type : "post",
            dataType : "json",
            data : {
                id : id,
                tag : tag,
                title : title,
                content : content,
                ctime : new Date().format("yyyy-MM-dd hh:mm:ss")
            },
            success : function(){

            }
        });
    }
</script>
</html>
